<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    //    题目一：用js写一个继承实例
    function Animal(color){
        this.color = color;  //因为每个动物有各自的颜色，new出实例时要针对性的传参进来
    }
    Animal.prototype = {//实例共用的方法才放在这里，若放构造方法，每个实例都创建一遍浪费资源
        eat:function(){
            console.log("不管是什么动物都有吃东西");
        }
    }

    function Dog(color,shuangYanPi){
        this.shuangYanPi = shuangYanPi;
        Animal.call(this,color);
    }
    Dog.prototype = new Animal();
    var boyFriend = new Dog("花的",true);
    boyFriend.eat();//



    function A(name,sex) {
        this.name = name;
        this.sex = sex;
    }

    function B(name,sex,goddess) {
        A.apply(this,[name,sex]);
        this.goddess = goddess;
    }
    var b = new B("sunquan","man","zyy");
    console.log(b.name+" "+b.sex+" "+b.goddess);

    function C(goddess,name,sex) {
        this.goddess = goddess;
        A.call(this,name,sex);
    }
    var c = new C("Mic","Jane","woman");
    console.log(c.name+" "+c.sex+" "+c.goddess);

    function D() {}
    var d = new D();
    A.call(d,"MaYun","MAN");
    console.log(d.name+" "+d.sex);
</script>
</body>
</html>